const userTemplate = '<nav class="navbar navbar-expand-lg main-navbar">\n' +
    '        <div class="form-inline mr-auto">\n' +
    '        </div>\n' +
    '        <ul class="navbar-nav navbar-right">\n' +
    '          <li class="dropdown"><a href="#" data-toggle="dropdown"\n' +
    '              class="nav-link dropdown-toggle nav-link-lg nav-link-user"> <img alt="image" :src="avatar"\n' +
    '                class="user-img-radious-style"> <span class="d-sm-none d-lg-inline-block"></span></a>\n' +
    '            <div class="dropdown-menu dropdown-menu-right pullDown">\n' +
    '              <div class="dropdown-title">Hello {{account}}</div>\n' +
    '              <div class="dropdown-divider"></div>\n' +
    '              <a href="#" @click="logout" class="dropdown-item has-icon text-danger"> <i class="fas fa-sign-out-alt"></i>\n' +
    '                退出\n' +
    '              </a>\n' +
    '            </div>\n' +
    '          </li>\n' +
    '        </ul>\n' +
    '      </nav>'
Vue.component('user-cart', {
    template: userTemplate,
    props:['avatar','account'],
    data() {
        return {

        }
    },
    methods: {
        getUserInfoList(){
            var userId = localStorage.getItem("userId");
            var account = localStorage.getItem("account");
            var nickName = localStorage.getItem("nickName");
            var avatar = localStorage.getItem("avatar");
            this.user.account = account;
            this.user.userId = userId;
            this.user.nickName = nickName;
            this.user.avatar = avatar;
        },
        logout() {
            sessionStorage.clear();
            layer.msg("退出成功",{icon:1,time:2000},function () {
                window.location.href = "Login.html"
            })
        }
    }
});
